package com.qzf.test.utils;

import com.qzf.test.model.Brand;

import java.util.Random;

public class BrandUtils {
    public static Random random=new Random();

    //定义一个数组存储卡牌的名称
    public static String [] brandNames={"刷子","剪刀","叉子","手套","水桶","火","玉米","球","瓶子","白菜",
            "稻草","肉腿","胡萝卜","苹果","铃铛","青草"};

    public static String getBrandName(){
        int index =random.nextInt(brandNames.length);
        return brandNames[index];
    }

    public static Brand[] builderBrand(int capacity){
        Brand [] brands =new Brand[capacity];
        for (int i=0;i<brands.length;i+=3){
            String brandName=getBrandName();
            Brand b1=new Brand(brandName);
            Brand b2=new Brand(brandName);
            Brand b3=new Brand(brandName);
            brands[i]=b1;
            brands[i+1]=b2;
            brands[i+2]=b3;
        }
        for (int i=0;i<brands.length;i++) {
            Brand brandA = brands[i];
            int randomIndex = random.nextInt(brands.length);
            Brand brandB = brands[randomIndex];

            brands[i]=brandB;
            brands[randomIndex]=brandA;
        }
        return  brands;
    }

}
